/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Model;

import java.io.Serializable;
import java.util.List;
import javax.persistence.*;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Sik
 */
@Entity
@Table(name = "equipe")
@XmlRootElement
@NamedQueries(
{
    @NamedQuery(name = "Equipe.findAll", query = "SELECT e FROM Equipe e"),
    @NamedQuery(name = "Equipe.findByIdEquipe", query = "SELECT e FROM Equipe e WHERE e.idEquipe = :idEquipe"),
    @NamedQuery(name = "Equipe.findByIntitule", query = "SELECT e FROM Equipe e WHERE e.intitule = :intitule"),
    @NamedQuery(name = "Equipe.findByDivision", query = "SELECT e FROM Equipe e WHERE e.division = :division")
})
public class Equipe implements Serializable
{
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idEquipe")
    private Integer idEquipe;
    @Column(name = "intitule")
    private String intitule;
    @Column(name = "division")
    private String division;
    @ManyToMany(mappedBy = "equipeList")
    private List<Adherent> adherentList;
    @JoinColumn(name = "id_capitaine", referencedColumnName = "idAdherent")
    @ManyToOne(optional = false)
    private Adherent idCapitaine;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "equipeidEquipe")
    private List<Competition> competitionList;

    public Equipe()
    {
    }

    public Equipe(Integer idEquipe)
    {
        this.idEquipe = idEquipe;
    }

    public Integer getIdEquipe()
    {
        return idEquipe;
    }

    public void setIdEquipe(Integer idEquipe)
    {
        this.idEquipe = idEquipe;
    }

    public String getIntitule()
    {
        return intitule;
    }

    public void setIntitule(String intitule)
    {
        this.intitule = intitule;
    }

    public String getDivision()
    {
        return division;
    }

    public void setDivision(String division)
    {
        this.division = division;
    }

    @XmlTransient
    public List<Adherent> getAdherentList()
    {
        return adherentList;
    }

    public void setAdherentList(List<Adherent> adherentList)
    {
        this.adherentList = adherentList;
    }

    public Adherent getIdCapitaine()
    {
        return idCapitaine;
    }

    public void setIdCapitaine(Adherent idCapitaine)
    {
        this.idCapitaine = idCapitaine;
    }

    @XmlTransient
    public List<Competition> getCompetitionList()
    {
        return competitionList;
    }

    public void setCompetitionList(List<Competition> competitionList)
    {
        this.competitionList = competitionList;
    }

    @Override
    public int hashCode()
    {
        int hash = 0;
        hash += (idEquipe != null ? idEquipe.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object)
    {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Equipe))
        {
            return false;
        }
        Equipe other = (Equipe) object;
        if ((this.idEquipe == null && other.idEquipe != null) || (this.idEquipe != null && !this.idEquipe.equals(other.idEquipe)))
        {
            return false;
        }
        return true;
    }

    @Override
    public String toString()
    {
        return "Model.Equipe[ idEquipe=" + idEquipe + " ]";
    }
    
}
